<?php

//headers
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization, X-Requested-With');

//index db
include_once('../../index.php');

//index properties
$post = new Post($db);

//receive properties
$data = json_decode(file_get_contents("php://input"));

//receive properties
$post->identify = $data->identify;
$post->hash = $data->hash;

//identify process
if (!$post->identify()) {
  echo json_encode(array('error' => 'No identify.'), JSON_PRETTY_PRINT);
  return;
}

$post->id = $data->id;
$post->softDelete = $data->softDelete;

//soft delete user
if ($post->soft_delete()) {
  echo json_encode(
    array('message' => 'Post updated.'),
    JSON_PRETTY_PRINT);
}
else {
  echo json_encode(
    array('error' => 'Post not updated.'),
    JSON_PRETTY_PRINT);
}

?>